namespace Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.SysConfig",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        ConfigKey = c.String(nullable: false, maxLength: 200),
                        ConfigValue = c.String(nullable: false, maxLength: 200),
                        CnName = c.String(maxLength: 200),
                        Description = c.String(maxLength: 2000),
                        Sort = c.Int(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysDepartment",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 200),
                        Description = c.String(maxLength: 2000),
                        Sort = c.Int(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysDictionary",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        ParentId = c.Guid(nullable: false),
                        DictName = c.String(nullable: false, maxLength: 200),
                        DictValue = c.String(nullable: false, maxLength: 200),
                        Description = c.String(maxLength: 2000),
                        Sort = c.Int(nullable: false),
                        Level = c.Int(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysLoginLog",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 200),
                        IpAddress = c.String(nullable: false, maxLength: 20),
                        MacAddress = c.String(nullable: false, maxLength: 50),
                        Description = c.String(maxLength: 2000),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysModule",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        ModuleName = c.String(nullable: false, maxLength: 200),
                        Url = c.String(nullable: false, maxLength: 200),
                        Description = c.String(maxLength: 2000),
                        Icon = c.String(maxLength: 200),
                        BtnId = c.Guid(nullable: false),
                        BtnClass = c.String(maxLength: 200),
                        Sort = c.Int(nullable: false),
                        ModuleLevel = c.Int(nullable: false),
                        IsAuthorize = c.Boolean(nullable: false),
                        ParentId = c.Guid(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysOperateLog",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 200),
                        IpAddress = c.String(nullable: false, maxLength: 20),
                        MacAddress = c.String(nullable: false, maxLength: 50),
                        Description = c.String(maxLength: 2000),
                        Action = c.String(nullable: false, maxLength: 200),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysOrganization",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Code = c.String(nullable: false, maxLength: 200),
                        Name = c.String(nullable: false, maxLength: 200),
                        ParentId = c.Guid(nullable: false),
                        Description = c.String(maxLength: 2000),
                        Sort = c.Int(nullable: false),
                        DepartmentId = c.Guid(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysPermission",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        RoleId = c.Guid(nullable: false),
                        ModuleId = c.Guid(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysRole",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 200),
                        Description = c.String(maxLength: 2000),
                        RoleType = c.Int(nullable: false),
                        Sort = c.Int(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysUserRole",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserId = c.Guid(nullable: false),
                        RoleId = c.Guid(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        DeleteTime = c.DateTime(),
                        SysRole_Id = c.Guid(),
                        SysUser_Id = c.Guid(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.SysRole", t => t.SysRole_Id)
                .ForeignKey("dbo.SysUser", t => t.SysUser_Id)
                .Index(t => t.SysRole_Id)
                .Index(t => t.SysUser_Id);
            
            CreateTable(
                "dbo.SysUser",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Code = c.String(nullable: false, maxLength: 200),
                        UserName = c.String(nullable: false, maxLength: 200),
                        PasswordHash = c.String(nullable: false, maxLength: 256),
                        Nick = c.String(maxLength: 200),
                        Gender = c.Byte(nullable: false),
                        IdCard = c.String(maxLength: 18),
                        PhoneNumber = c.String(maxLength: 11),
                        Email = c.String(maxLength: 200),
                        Birthday = c.DateTime(),
                        Address = c.String(maxLength: 2000),
                        Description = c.String(maxLength: 2000),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                        EmailConfirmed = c.Boolean(nullable: false),
                        SecurityStamp = c.String(),
                        PhoneNumberConfirmed = c.Boolean(nullable: false),
                        TwoFactorEnabled = c.Boolean(nullable: false),
                        LockoutEndDateUtc = c.DateTime(),
                        LockoutEnabled = c.Boolean(nullable: false),
                        AccessFailedCount = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysUserClaim",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CreateTime = c.DateTime(nullable: false),
                        UserId = c.Guid(nullable: false),
                        ClaimType = c.String(),
                        ClaimValue = c.String(),
                        SysUser_Id = c.Guid(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.SysUser", t => t.SysUser_Id)
                .Index(t => t.SysUser_Id);
            
            CreateTable(
                "dbo.SysUserLoginInfo",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserId = c.Guid(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        DeleteTime = c.DateTime(),
                        LoginProvider = c.String(),
                        ProviderKey = c.String(),
                        SysUser_Id = c.Guid(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.SysUser", t => t.SysUser_Id)
                .Index(t => t.SysUser_Id);
            
            CreateTable(
                "dbo.SysUserGroup",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Name = c.String(nullable: false, maxLength: 200),
                        Description = c.String(maxLength: 2000),
                        Sort = c.Int(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysUserGroupMember",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserGroupId = c.Guid(nullable: false),
                        UserId = c.Guid(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysUserGroupRole",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        RoleId = c.Guid(nullable: false),
                        UserGroupId = c.Guid(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.SysUserOrg",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        UserId = c.Guid(nullable: false),
                        OrganizationId = c.Guid(nullable: false),
                        IsDel = c.Boolean(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                        DeleteTime = c.DateTime(),
                        UpdateTime = c.DateTime(),
                        Status = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.SysUserRole", "SysUser_Id", "dbo.SysUser");
            DropForeignKey("dbo.SysUserLoginInfo", "SysUser_Id", "dbo.SysUser");
            DropForeignKey("dbo.SysUserClaim", "SysUser_Id", "dbo.SysUser");
            DropForeignKey("dbo.SysUserRole", "SysRole_Id", "dbo.SysRole");
            DropIndex("dbo.SysUserLoginInfo", new[] { "SysUser_Id" });
            DropIndex("dbo.SysUserClaim", new[] { "SysUser_Id" });
            DropIndex("dbo.SysUserRole", new[] { "SysUser_Id" });
            DropIndex("dbo.SysUserRole", new[] { "SysRole_Id" });
            DropTable("dbo.SysUserOrg");
            DropTable("dbo.SysUserGroupRole");
            DropTable("dbo.SysUserGroupMember");
            DropTable("dbo.SysUserGroup");
            DropTable("dbo.SysUserLoginInfo");
            DropTable("dbo.SysUserClaim");
            DropTable("dbo.SysUser");
            DropTable("dbo.SysUserRole");
            DropTable("dbo.SysRole");
            DropTable("dbo.SysPermission");
            DropTable("dbo.SysOrganization");
            DropTable("dbo.SysOperateLog");
            DropTable("dbo.SysModule");
            DropTable("dbo.SysLoginLog");
            DropTable("dbo.SysDictionary");
            DropTable("dbo.SysDepartment");
            DropTable("dbo.SysConfig");
        }
    }
}
